package com.ijustyce.denoise.Adapter;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;

import androidx.recyclerview.widget.RecyclerView;

import com.ijustyce.denoise.Activity.FileActivity;
import com.ijustyce.denoise.Items.buttons;
import com.ijustyce.denoise.R;


import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class ButtonAdapter extends RecyclerView.Adapter<ButtonAdapter.ViewHolder> {

    private List<buttons> List;


    public static class ViewHolder extends RecyclerView.ViewHolder {
        ImageButton Image;
       

        public ViewHolder(View view) {
            super(view);
            Image = (ImageButton) view.findViewById(R.id.icon);
        }
    }

    public ButtonAdapter(List<buttons> fruitList) {
        List = fruitList;
    }

    @Override
    public ViewHolder onCreateViewHolder(final ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_button, parent, false);
        final ViewHolder holder = new ViewHolder(view);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int position=holder.getAdapterPosition();
                Context context=parent.getContext();
                System.out.println("************");
                ButtonChange(position,context);

            }
        });
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        buttons good = List.get(position);
        holder.Image.setImageResource(good.getImageId());
    }

    @Override
    public int getItemCount() {
        return List.size();
    }

    @Override
    public long getItemId(int position) {
        return super.getItemId(position);
    }

    public void ButtonChange(int position,Context context){
        switch (position){
            case 0:
                Intent intent0=new Intent(context, FileActivity.class);
                context.startActivity(intent0);
                break;
            case 1:
                Intent intent1=new Intent(context, FileActivity.class);
                context.startActivity(intent1);
                break;
            case 2:
                Intent intent2=new Intent(context, FileActivity.class);
                context.startActivity(intent2);
                break;
            case 3:
                Intent intent3=new Intent(context, FileActivity.class);
                context.startActivity(intent3);
                break;
            case 4:
                Intent intent4=new Intent(context, FileActivity.class);
                context.startActivity(intent4);
                break;
        }



    }
}
